home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Meeting Pearls 2
/
Meeting Pearls Vol. II (1995)(GTI - Schatztruhe)[!].iso
/
Pearls
/
dev
/
Oberon4Amiga
/
Dialogs
/
DialogInsert.Mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1994-11-28
|
5KB
|
121 lines
Syntax10.Scn.Fnt
Syntax10i.Scn.Fnt
StampElems
Alloc
4 Nov 94
Syntax10b.Scn.Fnt
MODULE DialogInsert;
(* Markus Knasm
ller 3 Aug 94 -
IMPORT DialogFrames, DialogListBoxes, Dialogs, DialogTexts, Oberon, TextFrames, Texts;
PROCEDURE Open*;
VAR x, y: INTEGER; panel: Dialogs.Panel; w: Texts.Writer; t: Texts.Text; o: Dialogs.Object;
BEGIN
panel := Dialogs.cmdPanel;
o := panel.NamedObject ("l");
WITH o: DialogListBoxes.Item DO
Texts.OpenWriter (w);
Texts.WriteString (w, "CheckBox"); Texts.WriteLn (w);
Texts.WriteString (w, "Button"); Texts.WriteLn (w);
Texts.WriteString (w, "StaticText"); Texts.WriteLn (w);
Texts.WriteString (w, "RadioButton"); Texts.WriteLn (w);
Texts.WriteString (w, "GroupBox"); Texts.WriteLn (w);
Texts.WriteString (w, "Text"); Texts.WriteLn (w);
Texts.WriteString (w, "Line"); Texts.WriteLn (w);
Texts.WriteString (w, "Circle"); Texts.WriteLn (w);
Texts.WriteString (w, "Rectangle"); Texts.WriteLn (w);
Texts.WriteString (w, "Slider"); Texts.WriteLn (w);
Texts.WriteString (w, "IntegerSlider"); Texts.WriteLn (w);
Texts.WriteString (w, "Clock"); Texts.WriteLn (w);
Texts.WriteString (w, "AnalogClock"); Texts.WriteLn (w);
Texts.WriteString (w, "Date"); Texts.WriteLn (w);
Texts.WriteString (w, "ColorPicker"); Texts.WriteLn (w);
Texts.WriteString (w, "ListBox"); Texts.WriteLn (w);
Texts.WriteString (w, "ComboBox");
t := TextFrames.Text (""); Texts.Append (t, w.buf);
o.SetMenu (t)
ELSE HALT (99)
END
END Open;
PROCEDURE ReadInt (o: Dialogs.Object; VAR x, res: INTEGER);
(* reads an integer from a dialogtext element *)
VAR t: Texts.Text; s: Texts.Scanner;
BEGIN
WITH o: DialogTexts.Item DO
t := o.GetText (); Texts.OpenScanner (s, t, 0); Texts.Scan (s);
IF s.class = Texts.Int THEN x := SHORT (s.i); res := Dialogs.ok ELSE res := Dialogs.wrongInput END
ELSE
res := Dialogs.wrongInput
END;
END ReadInt;
PROCEDURE ReadName (o: Dialogs.Object; VAR x: ARRAY OF CHAR);
(* reads a name from the dialogtext element "name"*)
VAR t: Texts.Text; s: Texts.Scanner;
BEGIN
WITH o: DialogTexts.Item DO
t := o.GetText (); Texts.OpenScanner (s, t, 0); Texts.Scan (s);
IF s.class = Texts.Name THEN COPY (s.s, x) ELSE COPY ("", x) END
ELSE
COPY ("", x)
END
END ReadName;
PROCEDURE ReadXYWH (VAR x, y, w, h: INTEGER);
(* reads the lower left corner coordinates, wide and height from the Demo-Panel *)
VAR ox, oy, ow, oh: Dialogs.Object; i, res: INTEGER; panel: Dialogs.Panel;
BEGIN
panel := Dialogs.cmdPanel;
ox := panel.NamedObject ("x"); oy := panel.NamedObject ("y");
ow := panel.NamedObject ("w"); oh := panel.NamedObject ("h");
ReadInt (ox, i, res); IF res = 0 THEN x := i END;
ReadInt (oy, i, res); IF res = 0 THEN y := i END;
ReadInt (ow, i, res); IF res = 0 THEN w := i ELSE w := -1 END;
ReadInt (oh, i, res); IF res = 0 THEN h := i ELSE h := -1 END;
END ReadXYWH;
PROCEDURE ReadNameCmdPar (VAR name, cmd, par: ARRAY OF CHAR);
VAR on, op, oc: Dialogs.Object;
BEGIN
on := Dialogs.cmdPanel.NamedObject ("name"); oc := Dialogs.cmdPanel.NamedObject ("cmd");
op := Dialogs.cmdPanel.NamedObject ("par");
ReadName (on, name); ReadName (oc, cmd); ReadName (op, par)
END ReadNameCmdPar;
PROCEDURE Do*;
VAR
o, last: Dialogs.Object; p: Dialogs.Panel; name, cmd, par, insert: ARRAY 64 OF CHAR;
w0: Texts.Writer; t: Texts.Text; x, y, w, h, res: INTEGER;
BEGIN
DialogFrames.GetCaretPosition (p, x, y); last:= Dialogs.lastin;
ReadXYWH (x, y, w, h);
ReadNameCmdPar (name, cmd, par);
Texts.OpenWriter (w0); Texts.WriteString (w0, name); Texts.WriteString (w0, " ");
Texts.WriteInt (w0, x, 5); Texts.WriteInt (w0, y, 5); Texts.WriteInt (w0, w, 5); Texts.WriteInt (w0, h, 5);
t := TextFrames.Text (""); Texts.Append (t, w0.buf);
Oberon.Par.text := t;
o := Dialogs.cmdPanel.NamedObject ("l");
WITH o: DialogListBoxes.Item DO
IF o.selline = 0 THEN insert := "DialogCheckBoxes.Insert"
ELSIF o.selline = 1 THEN insert := "DialogButtons.Insert"
ELSIF o.selline = 2 THEN insert := "DialogStaticTexts.Insert"
ELSIF o.selline = 3 THEN insert := "DialogRadioButtons.Insert"
ELSIF o.selline = 4 THEN insert := "DialogGroupBoxes.Insert"
ELSIF o.selline = 5 THEN insert := "DialogTexts.Insert"
ELSIF o.selline = 6 THEN insert := "DialogLines.Insert"
ELSIF o.selline = 7 THEN insert := "DialogCircles.Insert"
ELSIF o.selline = 8 THEN insert := "DialogRectangles.Insert"
ELSIF o.selline = 9 THEN insert := "DialogSliders.Insert"
ELSIF o.selline = 10 THEN insert := "DialogIntegerSliders.Insert"
ELSIF o.selline = 11 THEN insert := "DialogClocks.Insert"
ELSIF o.selline = 12 THEN insert := "DialogAnalogClocks.Insert"
ELSIF o.selline = 13 THEN insert := "DialogDates.Insert"
ELSIF o.selline = 14 THEN insert := "DialogColorPickers.Insert"
ELSIF o.selline = 15 THEN insert := "DialogListBoxes.Insert"
ELSIF o.selline = 16 THEN insert := "DialogComboBoxes.Insert"
ELSE
END
ELSE
END;
Oberon.Call (insert, Oberon.Par, FALSE, res);
IF (Dialogs.lastin # last) & (par[0] # 0X) THEN Dialogs.lastin.SetPar (par) END;
IF (Dialogs.lastin # last) & (cmd[0] # 0X) THEN Dialogs.lastin.SetCmd (cmd) END;
END Do;
END DialogInsert.